import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
  //一级路由
  // {
  //   //重定项
  //   path: "/",
  //   redirect: "/classify",
  // },
  //测试重定项
  {
    //重定项
    path: "/",
    redirect: "/logreg",
  },
  //注册
  {
    path: "/logreg",
    component: () => import("@/views/LogReg.vue"),
    children: [
      {
        //重定项
        path: "/logreg",
        redirect: "/logreg/registry",
      },
      {
        path: "/logreg/loginphone",
        component: () => import("../views/logreg/Loginphone.vue"),
      },
      {
        path: "/logreg/loginpassword",
        component: () => import("../views/logreg/Loginpassword.vue"),
      },
      {
        path: "/logreg/registry",
        component: () => import("../views/logreg/Registry.vue"),
      },
    ],
  },
  //主页
  {
    path: "/index",
    component: () => import("@/views/Index.vue"),
    //二级路由
    children: [
      //重定项
      {
        path: "/index",
        redirect: "/index/store",
      },
      //商城首页
      {
        path: "/index/store", ///:userId
        component: () => import("@/views/index/Store.vue"),
      },
      //社区
      {
        path: "/index/community",
        component: () => import("../views/index/Community.vue"),
      },
      //消息
      {
        path: "/index/message",
        component: () => import("@/views/index/Message.vue"),
      },
      //我的
      {
        path: "/index/mine", ///:userid
        component: () => import("@/views/index/Mine.vue"),
        //跳转页面可以通过props获取数据
        props: true,
      },
    ],
  },
  //详情
  {
    path: "/detail/:productId",
    // path: "/detail",
    component: () => import("@/views/Detail.vue"),
    //跳转页面可以通过props获取数据
    props: true,
  },
  //购物车
  {
    path: "/cart",
    component: () => import("@/views/Cart.vue"),
    //跳转页面可以通过props获取数据
    props: true,
  },
  //订单
  {
    path: "/order",
    component: () => import("@/views/Order.vue"),
    //跳转页面可以通过props获取数据
    props: true,
  },
  // 确认订单
  {
    path: "/conorder",
    component: () => import("@/views/ConfirmOrder.vue"),
  },
  //
  //提交问题
  {
    // path: "/postquestion/:userid",
    path: "/postquestion",
    component: () => import("@/views/PostQuestion.vue"),
    //跳转页面可以通过props获取数据
    props: true,
  },
  //狗狗主粮
  {
    path: "/doggoods",
    component: () => import("@/views/DogGoods.vue"),
  },
  // 商城搜索
  {
    path: "/search",
    component: () => import("@/views/Search.vue"),
  },
  //商城分类
  {
    path: "/classify",
    component: () => import("@/views/Classify"),
  },
  //我的问题
  {
    path: "/minequestion",
    component: () => import("@/views/MineQuestions.vue"),
  },
  //问题详情
  {
    path: "/questiondetail/:quesid",
    component: () => import("@/views/QuestionDetail.vue"),
    //跳转页面可以通过props获取数据
    props: true,
  },
  //完善个人信息
  {
    path: "/changeinfo",
    component: () => import("@/views/ChangeInfo.vue"),
  },
  //添加宠物
  {
    path: "/addpet",
    component: () => import("@/views/AddPet.vue"),
  },
  //我的宠物
  {
    path: "/minepet",
    component: () => import("@/components/index/mine/MinePet.vue"),
  },

  // {
  //   //默认路由
  //   path: "*",
  //   //404页面
  //   component: () => import("@/views/404.vue"),
  // },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
